import Vue from 'vue'
import Router from 'vue-router'

import login from '@/components/login'
import regist from '@/components/regist'
import devMain from '@/components/devMain'
import orderType from '@/components/orderType'
import userInfo from '@/components/userInfo'
// import setPhone from '@/components/setPhone'
import payment from '@/components/payment'
import orderAdd from '@/components/orderAdd'
import deviceAdd from '@/components/deviceAdd'
import listAdd from '@/components/listAdd'
import orderDetails from '@/components/orderDetails'
import deviceDetails from '@/components/deviceDetails'

Vue.use(Router)

export default new Router({
  routes: [
    {
      // 默认路径重定向为未完成订单
      path: '/',
      redirect: '/dev_main/order_type/0'
    },
    {
      //用户登录绑定页面
      path: '/login',
      name: 'login',
      component: login
    },
    {
      //用户注册页面,'personalRegist'为个人用户注册,'businessRegist'为企业用户
      path: '/regist/:user_type',
      name: 'regist',
      component: regist
    },
    {
      path: '/dev_main',
      name: 'devMain',
      component: devMain,
      children: [
        {
          // is_complete：'0'为未完成订单,'1'为已完成订单
          path: '/dev_main/order_type/:is_complete',
          name: 'orderType',
          component: orderType
        },
        {
          // 用户个人信息
          path: '/dev_main/user_info',
          name: 'userInfo',
          component: userInfo
        },
        {
          // 支付页面
          path: '/dev_main/payment',
          name: 'payment',
          component: payment
        },
        {
          // 新增订单
          path: '/dev_main/order_add',
          name: 'orderAdd',
          component: orderAdd
        },
        {
          // 新增设备
          path: '/dev_main/device_add',
          name: 'deviceAdd',
          component: deviceAdd
        },
        {
          // 新增订单设备总页面
          path: '/dev_main/list_add',
          name: 'listAdd',
          component: listAdd
        },
        {
          // 订单详情,动态路由匹配
          path: '/dev_main/order_details/:orderId',
          name: "orderDetails",
          component: orderDetails
        },
        {
          // 设备详情,动态路由匹配
          path: '/dev_main/device_details/:deviceId',
          name: "deviceDetails",
          component: deviceDetails
        }
      ]
    }
    // {
    //   // 修改手机号
    //   path: '/user_info/set_phone',
    //   name: 'setPhone',
    //   component: setPhone
    // },
  ],
  scrollBehavior (to, from, savedPosition) {
   return { x: 0, y: 0 }
  }
})
